﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>客户数据源</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysFrameWork.js"></script>

    <script type="text/html" id="barDemo">

        <a title="编辑" href="javascript:;" lay-event="edit" id="update"><i class="layui-icon">&#xe642;</i></a>
        <a title="删除" href="javascript:;" lay-event="del" id="del"><i class="layui-icon">&#xe640;</i></a>
    </script>
</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var webCode = "";

    $(function () {
        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");
        loadData();
    })
    //赋值用户列表
    function loadData() {
        layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
            var laydate = layui.laydate //日期
                , laypage = layui.laypage //分页
                , layer = layui.layer //弹层
                , table = layui.table //表格
                , carousel = layui.carousel //轮播
                , upload = layui.upload //上传
                , element = layui.element //元素操作
                , slider = layui.slider //滑块
            var condition = JSON.stringify(FormToJson("qForm"));

            //给table赋值
            table.render({
                elem: '#list'
                //, width: 1030
                , url: '../System/getDataList?condition=' + condition + "&dataType=cdb" //数据接口
                , title: '系统用户表'
                , page: false //开启分页
                , even: true
                , limits: [20, 50, 80, 100]
                , cols: [[ //表头
                      { field: 'customName', title: '账套名称', width: 130, fixed: 'left' }
                    , { field: 'DbCode', title: '账套编码', width: 90 }
                    , { field: 'serverIp', title: 'IP地址', width: 120 }
                    , { field: 'baseName', title: '数据库名', width: 150 }
                    , { field: 'logid', title: '登录账号', width: 100 }
                    , { field: 'pwd', title: '登录密码', width: 110 }
                    , { field: 'isDefaultName', title: '是否默认', width: 80 }
                    , { field: 'statusName', title: '是否启用', width: 90 }
                    , { field: 'Id', title: 'id', width: 90 }
                    , { fixed: 'right', title: '操作', width: 100, align: 'center', toolbar: '#barDemo' }
                ]],done: function (res, curr, count) {
                    $("[data-field='Id']").css('display', 'none');//隐藏列
                    TablePowerHide();
            }
            });

            //监听行工具事件
            table.on('tool(list)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent == 'edit') {
                    InfoOpenPage('../System/UpdateCustomBase?dataId=' + data.DbCode, data.customName + "-修改", "85%", "80%", true);
                } else if (layEvent == 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        var info = DelData(data.Id);
                        if (info.result) {
                            obj.del();
                        } else {
                            layer.msg(info.message);
                        }
                        layer.close(index);
                    });

                }
            });
        });
    }

    function openWin() {
        InfoOpenPage("../System/UpdateCustomBase?dataId=0", "数据信息添加", "85%", "80%",true);
    }
   
    function DelData(id) {
        var info = undefined;
        $.ajax({
            url: "../System/delCustomBaseById",
            data: { dataId: id },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                info = data;
            }
        });
        return info;
    }


</script>